package com.birthdayapp.controller;

import com.birthdayapp.domain.CelebrateTimesVo;
import com.birthdayapp.entity.ResponseVO;
import com.birthdayapp.mapper.CelebrateMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/celebrate")
public class CelebrateController extends ABaseController{

    @Autowired
    private CelebrateMapper celebrateMapper;

    @PostMapping("/count")
    public ResponseVO Celebrate(String ipAddress){

        CelebrateTimesVo insertVo = new CelebrateTimesVo();
        insertVo.setCount(1);
        insertVo.setCreatedTime(new Date());
        insertVo.setIpAddress(ipAddress);
        int result = celebrateMapper.insert(insertVo);

        return getSuccessResponseVO(result != 0);
    }
}
